<?php
/**
 * 登录
 * ***********************
 * * Author:蜗牛他大哥    *
 * * Time: 2018-05-23    *
 * * QQ交流群：101766150  *
 * ***********************
 * */
namespace  app\img\controller;
use think\Controller;
use think\Session;

class login extends Controller{

    protected $name = 'admin';
    protected $pass = '123456';
    protected $nickName = '蜗牛他大哥';

    public function index(){

        print_r(session('login'));
       return $this->fetch();
    }
    public function login_ok(){


        $name = trim(input('name'));
        $password = intval(input('password'));

        if($name == $this->name && $password ==$this->pass){
            $session['name'] = $this->name;
            $session['nickName'] = $this->nickName;
           // 创建session
            session('login',$session);
           //跳转
            $this->redirect(url('img/index/index'));

        }else{
            $this->error('登录失败','img/index/index');
        }


    }
    public function out(){
        session::clear();
        $this->redirect(url('login/index'));
    }

}